import pytest
import os
from dotenv import load_dotenv
import shutil
from utils.allure_rename import get_json_data, write_json_data
load_dotenv(dotenv_path=os.path.join(os.path.dirname(__file__), '.env'))

if __name__ == '__main__':
    # 清理Allure临时目录
    temp_dir = os.path.join('allure', 'temp')
    if os.path.exists(temp_dir):
        shutil.rmtree(temp_dir)

    pytest.main([os.path.join('case', 'test_login.py'),'-q','--alluredir', temp_dir,'--clean-alluredir'])
    os.system(f'allure generate {temp_dir} -o {os.path.join("allure","allure-results")} --clean')

    # 自定义allure报告标题
    report_title = get_json_data('龙果UI自动化测试报告')
    write_json_data(report_title)
